package models

type ObjectById struct {
	Id  int   `uri:"id"`
	Ids []int `json:"ids"`
}
type MenuLabel struct {
	Id       int         `json:"id,omitempty" gorm:"-"`
	Label    string      `json:"label,omitempty" gorm:"-"`
	Children []MenuLabel `json:"children,omitempty" gorm:"-"`
}

//-------------------------role----------------------------//

type ReqRoleGetPage struct {
	Page int `json:"pageIndex" gorm:"-"`
	Size int `json:"pageSize" gorm:"-"`

	RoleId    int    `form:"roleId" search:"type:exact;column:role_id;table:sys_role" comment:"角色编码"`     // 角色编码
	RoleName  string `form:"roleName" search:"type:exact;column:role_name;table:sys_role" comment:"角色名称"` // 角色名称
	Status    string `form:"status" search:"type:exact;column:status;table:sys_role" comment:"状态"`        // 状态
	RoleKey   string `form:"roleKey" search:"type:exact;column:role_key;table:sys_role" comment:"角色代码"`   // 角色代码
	RoleSort  int    `form:"roleSort" search:"type:exact;column:role_sort;table:sys_role" comment:"角色排序"` // 角色排序
	Flag      string `form:"flag" search:"type:exact;column:flag;table:sys_role" comment:"标记"`            // 标记
	Remark    string `form:"remark" search:"type:exact;column:remark;table:sys_role" comment:"备注"`        // 备注
	Admin     bool   `form:"admin" search:"type:exact;column:admin;table:sys_role" comment:"是否管理员"`
	DataScope string `form:"dataScope" search:"type:exact;column:data_scope;table:sys_role" comment:"是否管理员"`
}

type RspRoleGetPage struct {
	Total int       `json:"total"`
	Page  int       `json:"page"`
	Size  int       `json:"size"`
	List  []SysRole `json:"list"`
}

type ReqRoleGet struct {
	Id int `form:"id" uri:"id"`
}

type ReqRoleInsert = SysRole
type ReqRoleUpdate = SysRole

type ReqRoleDelete struct {
	Ids []int `json:"ids"`
}

type ReqUpdateScope struct {
	RoleId    int    `json:"roleId"`
	DataScope string `json:"dataScope"`
	DeptIds   []int  `json:"deptIds"`
}

//-------------------------user----------------------------//

type ReqUserGetPage struct {
	Page int `form:"pageIndex" gorm:"-"`
	Size int `form:"pageSize" gorm:"-"`

	Username string `form:"username" gorm:"size:64;comment:用户名"`
	NickName string `form:"nickName" gorm:"size:128;comment:昵称"`
	Phone    string `form:"phone" gorm:"size:11;comment:手机号"`
	DeptId   int    `form:"deptId" gorm:"size:20;comment:部门"`
	Status   int    `form:"status" gorm:"size:4;comment:状态"`
}

type RspUserGetPage struct {
	Total int       `json:"total"`
	Page  int       `json:"pageIndex"`
	Size  int       `json:"pageSize"`
	List  []SysUser `json:"list"`
}

type ReqUserGet struct {
	Id int `form:"id" uri:"id"`
}

type ReqUserInsert = SysUser

type ReqUserUpdate = SysUser

type ReqUserDelete struct {
	Ids []int `json:"ids"`
}

type ReqUpdateSysUserStatus struct {
	UserId int    `json:"userId" comment:"用户ID" vd:"$>0"` // 用户ID
	Status string `json:"status" comment:"状态" vd:"len($)>0"`
	ControlBy
}

type ReqResetSysUserPwd struct {
	UserId   int    `json:"userId" comment:"用户ID" vd:"$>0"` // 用户ID
	Password string `json:"password" comment:"密码" vd:"len($)>0"`
	ControlBy
}

// ReqUpdatePwd 密码
type ReqUpdatePwd struct {
	NewPassword string `json:"newPassword" vd:"len($)>0"`
	OldPassword string `json:"oldPassword" vd:"len($)>0"`
}

type SysUserById struct {
	ObjectById
	ControlBy
}

//-------------------------menu----------------------------//

type ReqMenuGetPage struct {
	Page    int    `json:"pageIndex" search:"-"`
	Size    int    `json:"pageSize" search:"-"`
	Title   string `form:"title" search:"type:contains;column:title;table:sys_menu" comment:"菜单名称"`  // 菜单名称
	Visible int    `form:"visible" search:"type:exact;column:visible;table:sys_menu" comment:"显示状态"` // 显示状态
}

type ReqMenuGet struct {
	Id uint `form:"id" uri:"id"`
}

type ReqMenuInsert = SysMenu

type ReqMenuUpdate = SysMenu

type ReqMenuDelete struct {
	Ids []int `json:"ids"`
}

type ReqSelectRole struct {
	RoleId int `form:"roleId" uri:"roleId"`
}

type RspSelectRole struct {
	Menus       []MenuLabel `json:"menus"`
	CheckedKeys []int       `json:"checkedKeys"`
}

//-------------------------api----------------------------//

type ReqApiGetPage struct {
	Page     int    `form:"pageIndex" search:"-"`
	Size     int    `form:"pageSize" search:"-"`
	Title    string `form:"title"  search:"type:contains;column:title;table:sys_api" comment:"标题"`
	Path     string `form:"path"  search:"type:contains;column:path;table:sys_api" comment:"地址"`
	Action   string `form:"action"  search:"type:exact;column:action;table:sys_api" comment:"请求方式"`
	ParentId string `form:"parentId"  search:"type:exact;column:parent_id;table:sys_api" comment:"按钮id"`
	Type     string `form:"type" search:"-" comment:"类型"`
}

type RspApiGetPage struct {
	Total int      `json:"total"`
	Page  int      `json:"pageIndex"`
	Size  int      `json:"pageSize"`
	List  []SysApi `json:"list"`
}

type ReqApiGet struct {
	Id int `form:"id" uri:"id"`
}

type ReqApiInsert = SysApi

type ReqApiUpdate = SysApi

type ReqApiDelete struct {
	Ids []int `json:"ids"`
}

//-------------------------dept----------------------------//

// ReqDeptGetPage 列表或者搜索使用结构体
type ReqDeptGetPage struct {
	DeptId   int    `form:"deptId" search:"type:exact;column:dept_id;table:sys_dept" comment:"id"`       //id
	ParentId int    `form:"parentId" search:"type:exact;column:parent_id;table:sys_dept" comment:"上级部门"` //上级部门
	DeptPath string `form:"deptPath" search:"type:exact;column:dept_path;table:sys_dept" comment:""`     //路径
	DeptName string `form:"deptName" search:"type:exact;column:dept_name;table:sys_dept" comment:"部门名称"` //部门名称
	Sort     int    `form:"sort" search:"type:exact;column:sort;table:sys_dept" comment:"排序"`            //排序
	Leader   string `form:"leader" search:"type:exact;column:leader;table:sys_dept" comment:"负责人"`       //负责人
	Phone    string `form:"phone" search:"type:exact;column:phone;table:sys_dept" comment:"手机"`          //手机
	Email    string `form:"email" search:"type:exact;column:email;table:sys_dept" comment:"邮箱"`          //邮箱
	Status   string `form:"status" search:"type:exact;column:status;table:sys_dept" comment:"状态"`        //状态
}

type ReqDeptInsert struct {
	DeptId   int    `uri:"id" comment:"编码"`                                         // 编码
	ParentId int    `json:"parentId" comment:"上级部门" vd:"?"`                         //上级部门
	DeptPath string `json:"deptPath" comment:""`                                    //路径
	DeptName string `json:"deptName" comment:"部门名称" vd:"len($)>0"`                  //部门名称
	Sort     int    `json:"sort" comment:"排序" vd:"?"`                               //排序
	Leader   string `json:"leader" comment:"负责人" vd:"@:len($)>0; msg:'leader不能为空'"` //负责人
	Phone    string `json:"phone" comment:"手机" vd:"?"`                              //手机
	Email    string `json:"email" comment:"邮箱" vd:"?"`                              //邮箱
	Status   int    `json:"status" comment:"状态" vd:"$>0"`                           //状态
	ControlBy
}

type RspDeptInsert struct {
	Id int `json:"id"`
}

type ReqDeptUpdate struct {
	DeptId   int    `uri:"id" comment:"编码"`                                         // 编码
	ParentId int    `json:"parentId" comment:"上级部门" vd:"?"`                         //上级部门
	DeptPath string `json:"deptPath" comment:""`                                    //路径
	DeptName string `json:"deptName" comment:"部门名称" vd:"len($)>0"`                  //部门名称
	Sort     int    `json:"sort" comment:"排序" vd:"?"`                               //排序
	Leader   string `json:"leader" comment:"负责人" vd:"@:len($)>0; msg:'leader不能为空'"` //负责人
	Phone    string `json:"phone" comment:"手机" vd:"?"`                              //手机
	Email    string `json:"email" comment:"邮箱" vd:"?"`                              //邮箱
	Status   int    `json:"status" comment:"状态" vd:"$>0"`                           //状态
	ControlBy
}

type ReqDeptGet struct {
	Id int `uri:"id"`
}

type DeptLabel struct {
	Id       int         `gorm:"-" json:"id"`
	Label    string      `gorm:"-" json:"label"`
	Children []DeptLabel `gorm:"-" json:"children"`
}

//-------------------------post----------------------------//

// ReqPostPage 列表或者搜索使用结构体
type ReqPostPage struct {
	Page     int    `form:"pageIndex" search:"-"`
	Size     int    `form:"pageSize" search:"-"`
	PostId   int    `form:"postId" search:"type:exact;column:post_id;table:sys_post" comment:"id"`        // id
	PostName string `form:"postName" search:"type:contains;column:post_name;table:sys_post" comment:"名称"` // 名称
	PostCode string `form:"postCode" search:"type:contains;column:post_code;table:sys_post" comment:"编码"` // 编码
	Sort     int    `form:"sort" search:"type:exact;column:sort;table:sys_post" comment:"排序"`             // 排序
	Status   int    `form:"status" search:"type:exact;column:status;table:sys_post" comment:"状态"`         // 状态
	Remark   string `form:"remark" search:"type:exact;column:remark;table:sys_post" comment:"备注"`         // 备注
}

type RspPostPage struct {
	Page  int       `json:"pageIndex"`
	Size  int       `json:"pageSize"`
	Total int       `json:"total"`
	List  []SysPost `json:"list"`
}

// ReqPostInsert 增使用的结构体
type ReqPostInsert struct {
	PostId   int    `uri:"id"  comment:"id"`
	PostName string `form:"postName"  comment:"名称"`
	PostCode string `form:"postCode" comment:"编码"`
	Sort     int    `form:"sort" comment:"排序"`
	Status   int    `form:"status"   comment:"状态"`
	Remark   string `form:"remark"   comment:"备注"`
	ControlBy
}

// ReqPostUpdate 改使用的结构体
type ReqPostUpdate struct {
	PostId   int    `uri:"id"  comment:"id"`
	PostName string `form:"postName"  comment:"名称"`
	PostCode string `form:"postCode" comment:"编码"`
	Sort     int    `form:"sort" comment:"排序"`
	Status   int    `form:"status"   comment:"状态"`
	Remark   string `form:"remark"   comment:"备注"`
	ControlBy
}

// ReqPostGet 获取单个的结构体
type ReqPostGet struct {
	Id int `uri:"id"`
}

// ReqPostDelete 删除的结构体
type ReqPostDelete struct {
	Ids []int `json:"ids"`
	ControlBy
}

//-------------------------util----------------------------//

type ReqLogin struct {
	Code     string `json:"code"`
	UserName string `json:"username"`
	Password string `json:"password"`
	UUid     string `json:"uuid"`
}
type RspLogin struct {
	Token  string `json:"token"`
	Expire int64  `json:"expire"`
	Role   string `json:"role"`
}

type RspCaptcha struct {
	Id   string `json:"id"`
	Data string `json:"data"`
}

type RspGetInfo struct {
	Avatar      string   `json:"avatar"`
	Buttons     []string `json:"buttons"`
	DeptId      int      `json:"deptId"`
	Name        string   `json:"name"`
	Roles       []string `json:"roles"`
	UserId      int      `json:"userId"`
	UserName    string   `json:"userName"`
	Permissions []string `json:"permissions"`
}

type ReqDeptDelete struct {
	Ids []int `json:"ids"`
}

type ReqGetDeptTreeRoleSelect struct {
	Id int `json:"roleId" uri:"roleId"`
}

type RspGetDeptTreeRoleSelect struct {
	Depts       []DeptLabel `json:"depts"`
	CheckedKeys []int       `json:"checkedKeys"`
}
